package com.ruoyi.project.common;


import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.framework.sms.SmsClient;
import com.ruoyi.framework.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 获取验证码
 */
@RestController
public class SmsController {


    @Autowired
    SmsClient smsClient;

    @GetMapping("/getCode")
    public AjaxResult getCode(@RequestParam("phone") String phone){
        String code = String.format("%04d", UUID.getRandom().nextInt(0, 9999));
        smsClient.sendCode(phone, code);
        return AjaxResult.success("发送成功");
    }
}
